package Org.csmzxy.class2333;

class Car {
    private String brand;
    private String madel;
    private String engine;
    //无参构方法
    public Car(){
        System.out.println("调用有参构造方法，成功为属性赋初始值");
    }
    //有参构造方法
    public Car(String brand,String model,String engine){
        System.out.println("调用有参构造方法，成功为属性赋初始值");
        this.brand = brand;
        this.madel = model;
        this.engine = engine;
    }
    public void print(){
        System.out.println("该汽车的品牌为"+brand);
        System.out.println("该汽车的型号为"+madel);
        System.out.println("该汽车的发动机为"+engine);
    }
}
public class Example05{
    public static void main(String[] args){
        //调用无参构造方法
        Car car1 = new Car();
        car1.print();
        //调用有参构造方法
        Car car2 = new Car("奥迪","A6","V6w涡轮增压发动机");
        car2.print();
    }
}
